home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.19950726-19950929 / 000264_news@columbia.edu_Thu Aug 31 15:16:54 1995.msg < prev    next >
Internet Message Format  |  2020-01-01  |  12KB

  1. Received: from apakabar.cc.columbia.edu by watsun.cc.columbia.edu with SMTP id AA17420
  2.   (5.65c+CU/IDA-1.4.4/HLK for <kermit.misc@watsun.cc.columbia.edu>); Thu, 31 Aug 1995 12:32:39 -0400
  3. Received: by apakabar.cc.columbia.edu id AA11175
  4.   (5.65c+CU/IDA-1.4.4/HLK for kermit.misc@watsun); Thu, 31 Aug 1995 12:32:36 -0400
  5. Path: news.columbia.edu!panix!news.mathworks.com!tank.news.pipex.net!pipex!lade.news.pipex.net!pipex!sunic!sunic.sunet.se!news.isnet.is!news.ismennt.is!news
  6. From: halldorg@ismennt.is (Halldor Gudmundssson)
  7. Newsgroups: comp.protocols.kermit.misc
  8. Subject: Re: kermit script for unix
  9. Date: Thu, 31 Aug 1995 15:16:54 GMT
  10. Organization: Islenska Menntanetid (The icelandic edu. Network)
  11. Lines: 335
  12. Distribution: world
  13. Message-Id: <424kfg$1jo@folda.ismennt.is>
  14. References: <DE3yCz.Fzz@utnetw.utoledo.edu>
  15. Reply-To: halldorg@ismennt.is
  16. Nntp-Posting-Host: rvik.ismennt.is
  17. X-Newsreader: Forte Free Agent 1.0.82
  18. Apparently-To: kermit.misc@watsun.cc.columbia.edu
  19.  
  20. crszczub@cse.utoledo.edu (craig szczublewski) wrote:
  21.  
  22. >I just downloaded the new version of ms kermit and have been trying to 
  23. >set up a script as to automatically log into a unix machine (ie, standard
  24. >login:, password:) and I cannot get it to work.  It's like it does not
  25. >even see the incoming charcters.  I have set up scripts like this before
  26. >for 5A(190) under AIX and SCO, but this is my first attempt at an ms-dos
  27. >machine.  Any helpfull insights for migrating scripts from unix to dos?
  28.  
  29. >thanks in advance
  30.  
  31. >--
  32. >  +---------------------------+      +------------------------------------+
  33. >  |     Craig Szczublewski    |+     |  crszczub@jupiter.cse.utoledo.edu  |+
  34. >  |    Unique Systems, Inc.   ||     |   4gen!unique!craig%uunet.uu.net   ||
  35. >  | 5610 Monroe St. Suite 210 ||     |------------------------------------||
  36. >  |     Sylvania, OH 43560    ||     | A system without COBOL or FORTRAN  || 
  37. >  |       (419) 882-1113      ||     | is like a piece of chocolate cake  ||
  38. >  |     FAX (419) 882-2911    ||     |    without ketchup and mustard     ||
  39. >  +---------------------------+|     +------------------------------------+|
  40. >   +---------------------------+      +------------------------------------+
  41.  
  42. this is a script and you should run kermit from batchfile like
  43.  
  44. @echo off
  45. kermit def passwd <yourpassw> ,def userid <youruid>, take k1.scr, stay
  46.  
  47.  
  48. define getout out \13,-
  49.  inp 3 >,-
  50.  if succ out exit\13,-
  51.  inp 10 >,-
  52.  if succ hangup,out +++ATH\13, pause 5, out ath\13,pause 2,-
  53.  exit
  54. set key \2320 {\Kgetout}                ; Assign GETOUT macro to
  55. Alt-Q. 
  56. set com3 \x3E8 11
  57. Set PORT 3
  58. SET BAUD 19200
  59. SET FLOW rts
  60. SET DISP 8
  61. SET TERM BELL NONE
  62. SET RECEIVE PACKET 2000
  63. SET TRANSLATE INPUT ON
  64. SET WINDOWS 4
  65. set transfer char latin1
  66. set input timeout proceed       ; Allow IF SUCCESS, IF FAILURE
  67. set input echo on                ; Don't echo the modem test
  68.  
  69. ; Define ERRSTOP macro to issue an error message and stop.
  70. ;
  71. define errstop echo \%1, hangup, stop
  72. ; FILE MT1432.SCR (MSMT1432.SCR)
  73. ;
  74. ; An MS-DOS Kermit script program for dialing the Multitech MT1432
  75. series 
  76. ; modems, to be used with MS-DOS Kermit 3.12 or later.  The modem is
  77. set 
  78. ; for compression, error correction, all types of fallback, RTS/CTS 
  79. ; flow control, and a fixed interface speed of 57600 or 38400.
  80. ;
  81. ; Authors: Christine M. Gianone, Frank da Cruz, Max Evarts; 
  82. ; Columbia University, June 1993
  83. ; Modified May 1994 to remove DSR check (Peter Mossel)
  84. ;
  85. def errfail echo \%1, hangup, goto fail ; Macro to handle failures.
  86. if < VERSION 312 errfail {MS-DOS Kermit 3.12 or later required.}
  87. if eq "\v(system)" "UNIX" if = \v(local) 0 stop 1 You must SET LINE
  88. first
  89.  
  90. define chkerr if fail stop 1 \%1
  91. define chkok input 3 OK, if fail stop 1 \%1
  92.  
  93. set input echo on               ; So we can watch what happens.
  94. set input timeout proceed       ; Allow IF SUCCESS, IF FAILURE.
  95. set input case ignore           ; Use caseless string comparisons
  96.  
  97. set parity none                 ; Avoid parity foulups
  98. set flow none                   ; Avoid flow control deadlocks
  99. hangup                          ; Begin by dropping DTR
  100. pause 1                         ; for one second
  101.  
  102. ; Speed.  Don't worry about modem, it autobauds up to 57600.
  103.  
  104. set speed 19200                 ; If computer can be set to 57600 bps,
  105. use it.
  106. if fail set speed 9600         ; If not, use 19200.
  107.  
  108. echo Configuring MultiTech MT1432 on \v(line).
  109.  
  110. :INIT
  111. output ATQ0V1\13                ; Enable word result codes
  112. chkok {Can't get modem's attention}
  113.  
  114. output AT E1 &Q1 X4\13          ; Echoing, result codes, etc.
  115. chkok {Can't initialize modem}
  116.  
  117. echo Enabling modulation negotiation...
  118. output AT $SB\v(speed) $MB19200\13      ; Start modulation speed
  119. negotiation
  120.                     ; at V32bis, set interface speed
  121. chkok {Can't enable modulation speed negotiation}
  122. echo Enabling hardware flow control...
  123. output AT &E4\13                ; RTS/CTS hardware flow control
  124. chkok {Can't enable RTS/CTS}    ; On modem
  125. wait 5 cts
  126. if fail errfail {Modem is not asserting CTS!}
  127. set flow rts/cts                ; And in Kermit too, but only now
  128. echo Configuring modem to ignore BREAK...
  129. output AT %E1\13                ; Make modem ignore BREAK
  130. chkok {Can't become transparent to BREAK}
  131. echo Enabling error correction and data compression...
  132. output AT &E1 &E15 $BA0\13      ; Enable error correction &
  133. compression
  134.                 ; with automatic speed buffering 
  135. chkok {Can't enable compression EC and fallback}
  136.  
  137. :BEGIN                          ; Now DIAL.
  138. clear                           ; Clear INPUT buffer.
  139. set count 5                     ; Dialing retry counter, 5 tries
  140. allowed.
  141. echo Dialing 5811100 on \v(line) at \v(speed) bps, wait...
  142. echo
  143. pause 1
  144. goto dial                       ; 1st time, skip pause and Redialing
  145. message
  146.  
  147. :REDIAL
  148. set alarm 30
  149. pause 30                        ; Wait 30 seconds before redialing.
  150. if not alarm errfail {Dialing canceled.}
  151. echo Redialing...               ; Message for redialing.
  152. pause 1
  153.  
  154. :DIAL
  155. output ATDT5811100\13                ; Dial the number.
  156. set alarm 90                    ; (For detecting keyboard
  157. interruptions.)
  158. if > VERSION 312 clear input    ; Clear echo from INPUT buffer.
  159. if < VERSION 313 clear
  160. input 30 \10                    ; Wait for the linefeeds...
  161.  
  162. :GETMSG
  163. input 60 \10                    ; ...that surround the response
  164. message.
  165. if success goto gotmsg          ; Got a message.
  166. if alarm errfail {No response from modem.} ; No response in 90
  167. seconds.
  168. hangup                          ; User interrupted from keyboard,
  169. output \13                      ; cancel dialing by sending carriage
  170. return,
  171. goto again                      ; and go try again right away.
  172.  
  173. :GOTMSG
  174. reinput 1 CONNECT               ; Got a message, was it CONNECT?
  175. if success goto done            ; If so, we're done.
  176. reinput 1 BUSY                  ; Line is busy.
  177. if success goto busy            ; Go wait a while and then dial again.
  178. reinput 1 ERROR                 ; Command syntax error.
  179. if success errfail {Dialing command error}
  180. reinput 1 NO CARRIER            ; Phone didn't answer or no carrier.
  181. if success errfail {No answer or no carrier}
  182. reinput 1 NO DIALTONE           ; No dialtone when phone taken off
  183. hook.
  184. if success errfail {No dialtone - Is your modem connected to the phone
  185. line\63}
  186. goto getmsg                     ; None of the above, get another
  187. message.
  188.  
  189. :BUSY
  190. if < \v(count) 2 goto quit      ; Don't wait 30 seconds if tries are
  191. used up.
  192. echo Line is busy, will dial again in 30 seconds.
  193. echo Press any key to cancel...
  194. output \13                      ; CR cancels dialing
  195. hangup                          ; Hang up.
  196. :AGAIN
  197. if count goto redial            ; Then go redial.
  198. :QUIT
  199. errfail {It never answers!  I give up.} ; Too many tries.
  200.  
  201. :DONE                           ; Connected.
  202. echo \7                         ; Celebrate with a beep.
  203. input 20 ):
  204. output 1\13
  205. goto login
  206. define errfail                  ; Erase local macro definitions...
  207. end 0                           ; Finished, return success code.
  208.  
  209. :FAIL                           ; Dialing failed, no beep.
  210. define errfail                  ; Erase local macro definitions...
  211. end 1                           ; Return failure code.
  212.  
  213. ; End of MT1432.SCR
  214.  
  215. ; Action starts here
  216. ; If they typed their password on the DOS command line,
  217. ; clear the screen now.
  218. ;
  219. if def passwd cls                       ; for security...
  220. def \%9                                 ; "Thank you" flag.
  221. if def userid goto askpw
  222.  
  223. :XUID
  224. ;
  225. ; User ID wasn't specified on command line, so prompt for it.
  226. ;
  227. ask \%8 {Enter your userid   Enter: }
  228. if not def \%8 goto XUID
  229. assign userid \%8
  230. def \%9 Thank you.
  231.  
  232. :ASKPW
  233. if def passwd goto thanks
  234. :XPWD
  235. ;
  236. ; Password wasn't specified on command line, so prompt for it.
  237. ;
  238. askq \%8 -
  239.   {Enter Password (it will not echo) and press   ENTER: }
  240. if not def \%8 goto XPWD
  241. assign passwd \%8
  242. def \%9 Thank you.
  243.  
  244. :THANKS
  245. def \%8                         ; Erase password from memory
  246. if def \%9 echo \%9             ; Be polite
  247. def \%9
  248. echo
  249. set input case ignore           ; Don't care about alphabetic case.
  250. hangup                          ; Hang up any current data connection.
  251.  
  252. set input timeout proceed       ; Allow IF SUCCESS, IF FAILURE
  253. set input echo on                ; Don't echo the modem test
  254. output ATQ0V1X1\13              ; Send AT, use word result codes.
  255. input 5 OK                      ; Modem should say "OK"
  256. Output \13
  257.  
  258. Set count 4
  259. :LOOP       
  260. output \13AT\13                 ; Give the Hayes modem AT command
  261. input 5 OK                      ; Look for Hayes OK response.
  262. if failure goto RETRY           ; Not found, try again.
  263. echo Hringi ! menntaneti  ...           ; It's 244PC, tell the user.
  264. output ATDT5683370\13           ; Make a data call to "[CUNIX]".
  265. input 30 CONNECT          ; Look for modem's confirmation.
  266. if success goto GOOD
  267.  
  268. :RETRY
  269. if count goto LOOP
  270. set count 4
  271. :L2
  272. output ATDT5811100\13
  273. input 30 CONNECT
  274. if success goto GOOD2
  275. if count goto L2
  276. ; Get here when there is no communication after 3 tries.
  277. ;
  278. echo
  279. echo {  Modem not answering.}
  280. echo {  You are using port \v(port),  and speed  is  \v(speed).}
  281. echo {  if this is not correct   use SET PORT in  Kermit}
  282. echo {  and   SET SPEED and try again.}
  283. echo {  Check if modem is connected and }
  284. echo {   that it is powered on}
  285. echo
  286. hangup
  287. stop
  288.  
  289. :GOOD
  290. ; We got through, one way or the other.
  291. ; Send carriage returns for speed recognition.
  292. ; Try up to 5 times to get Info terminal server prompt, "blah>".
  293. ;
  294. set count 5                     ; Loop counter.
  295.  
  296. :AGAIN
  297. output \13                      ; Send CR for speed recognition.
  298. input 20 >                      ; Look for prompt.
  299. if success goto INFO            ; If found, proceed with login
  300. process,
  301. if count goto again             ; otherwise continue the loop.
  302. errstp {Failed to connect to main computer - try again}
  303.  
  304. :INFO
  305. goto UNA
  306. set count 5
  307. :GOOD2
  308. input 20 ):
  309. if success goto RVIK 
  310. out +++ATH\13
  311. pause 5
  312. out ath\13
  313. pause 2 
  314. if count goto RETRY
  315. errstp {No answere from machinhe.}
  316. :RVIK
  317. output 1\13
  318. input 20 login:
  319. if fail errstop {Did not get login }
  320.  
  321. GOTO LOGIN
  322. ;
  323. ; Got terminal server prompt, select cunix and wait for login prompt.
  324. ;
  325. :UNA
  326. output una\13
  327. input 20 login:
  328. if fail errstop {did not get login prompt - try again}
  329.  
  330. :LOGIN
  331. ;
  332. ; Got "login:" prompt, send user ID and look for "Password:" prompt.
  333. ;
  334. output \m(userid)\13            ; Send user ID, followed by CR.
  335. input 20 Password:              ; Wait up to 5 seconds for "Password:"
  336. prompt.
  337. if fail errstop {did not get password prompt}
  338.  
  339. ; Send user's password, then wait for shell prompt.
  340. ; Here we must figure out whether it is "$ " or "% ".
  341. ; If it is anything else, such as "cunixa:", that must be
  342. ; predefined (see top of this file).
  343. ;
  344. output \m(passwd)\13            ; Send password.
  345. define passwd                   ; Erase from memory.
  346.  
  347. ; Now try to get the shell prompt.
  348. ;
  349. CONNECT
  350.  
  351. Halldor Gudmundsson
  352. halldorg@ismennt.is
  353. http://rvik.ismennt.is/~halldorg
  354.